
component output="false" extends="AbsService" accessors="true" {

	// Delegate
	property name="SettingDelegate" type="it.millemultimedia.easyBlog.delegate.SettingDelegate";

	public it.millemultimedia.easyBlog.service.SettingService function init(){
		
		return this;
	}
	
	public it.millemultimedia.easyBlog.validator.SettingValidator function getValidator(){
		
		return getSettingDelegate().getValidator();
	}
	
	public it.millemultimedia.easyBlog.model.Setting function new(){
		
		return getSettingDelegate().createInstance();
	}
	
	public it.millemultimedia.easyBlog.model.Setting function getSetting( required Any Setting ){
		
		return getSettingDelegate().read( arguments.Setting );
	}
	
	public it.millemultimedia.easyBlog.model.Setting[] function getSettings(){
		
		return getSettingDelegate().list( arguments.Setting );
	}
	
	public boolean function settingExists( required Any Setting ){
		var result = getSettingDelegate().list( arguments.Setting );
		
		return arrayLen( result ) gt 0;
	}
	
	public void function saveSetting( required Any Setting ){
	
		transaction{
		
			try{
				
				
				if( arguments.Setting.getidSetting()  eq 0 ){
				
					this.createSetting( arguments.Setting );
				
				}else if( arguments.Setting.getIdSetting() gt 0 ){
				
					this.updateSetting( arguments.Setting );
				
				}else{
				
					throw( message="Setting id property have undefined value." );
				
				}
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function createSetting( required Any Setting ){
	
		transaction{
		
			try{
			
				getSettingDelegate().create( arguments.Setting );
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function updateSetting( required Any Setting ){
	
		transaction{
		
			try{
			
				getSettingDelegate().update( arguments.Setting );
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
			
			}
		
		}
		
	}
	
	public void function deleteSetting( required Any Setting ){
	
		transaction{
		
			try{
			
				getSettingDelegate().delete( arguments.Setting );
				
			
			}catch( except Any ){
			
				transaction action="rollback";
				
				throw( except.message );
							
			}
			
		}
		
	}
	
}
